import { CatDir, GameCatAnimData } from "../GameDefine";
import { AnimMgr } from "../managers/AnimMgr";

/**
 * 小猫-配置数据
 * @Author: lzmxqh  
 * @Date: 2022-10-23 18:18:38  
 * @Last Modified by: lzmxqh
 * @Last Modified time: 2022-10-23 22:39:04
 */
export class CatConfig {
    /**猫配置数据 */
    public static CAT_CONFIG: { [dir: number]: GameCatAnimData } = {
        [CatDir.LEFT]: {
            /**x缩放 */
            scaleX: 1,
            /**动画名 */
            animName: "left",
            /**原点x */
            originX: 0.73,
            /**原点y */
            originY: 0.7
        },
        [CatDir.RIGHT]: {
            /**x缩放 */
            scaleX: -1,
            /**动画名 */
            animName: "left",
            /**原点x */
            originX: 0.73,
            /**原点y */
            originY: 0.7
        },
        [CatDir.TOP_LEFT]: {
            /**x缩放 */
            scaleX: 1,
            /**动画名 */
            animName: "top_left",
            /**原点x */
            originX: 0.63,
            /**原点y */
            originY: 0.75
        },
        [CatDir.TOP_RIGHT]: {
            /**x缩放 */
            scaleX: -1,
            /**动画名 */
            animName: "top_left",
            /**原点x */
            originX: 0.63,
            /**原点y */
            originY: 0.75
        },
        [CatDir.BOTTOM_LEFT]: {
            /**x缩放 */
            scaleX: 1,
            /**动画名 */
            animName: "bottom_left",
            /**原点x */
            originX: 0.65,
            /**原点y */
            originY: 0.4
        },
        [CatDir.BOTTOM_RIGHT]: {
            /**x缩放 */
            scaleX: -1,
            /**动画名 */
            animName: "bottom_left",
            /**原点x */
            originX: 0.65,
            /**原点y */
            originY: 0.4
        }
    };

    /**小猫-动画数据 */
    public static CAT_ANIM_CONFIG: { [name: string]: Phaser.Types.Animations.Animation } = {
        ["left_step"]: {
            key: "left_step",
            frames: [
                {
                    key: "L01",
                    frame: 0
                },
                {
                    key: "L02",
                    frame: 0
                },
                {
                    key: "L03",
                    frame: 0
                },
                {
                    key: "L04",
                    frame: 0
                },
                {
                    key: "L05",
                    frame: 0
                }
            ],
            frameRate: 15,
            repeat: 0
        },
        ["top_left_step"]: {
            key: "top_left_step",
            frames: [
                {
                    key: "TL01",
                    frame: 0
                },
                {
                    key: "TL02",
                    frame: 0
                },
                {
                    key: "TL03",
                    frame: 0
                },
                {
                    key: "TL04",
                    frame: 0
                },
                {
                    key: "TL05",
                    frame: 0
                }
            ],
            frameRate: 15,
            repeat: 0
        },
        ["bottom_left_step"]: {
            key: "bottom_left_step",
            frames: [
                {
                    key: "BL01",
                    frame: 0
                },
                {
                    key: "BL02",
                    frame: 0
                },
                {
                    key: "BL03",
                    frame: 0
                },
                {
                    key: "BL04",
                    frame: 0
                },
                {
                    key: "BL05",
                    frame: 0
                }
            ],
            frameRate: 15,
            repeat: 0,
        },
        ["left_run"]: {
            key: "left_run",
            frames: [
                {
                    key: "L02",
                    frame: 0
                },
                {
                    key: "L03",
                    frame: 0
                },
                {
                    key: "L04",
                    frame: 0
                },
                {
                    key: "L05",
                    frame: 0
                }
            ],
            frameRate: 15,
            repeat: 3,
        },
        ["top_left_run"]: {
            key: "top_left_run",
            frames: [
                {
                    key: "TL02",
                    frame: 0
                },
                {
                    key: "TL03",
                    frame: 0
                },
                {
                    key: "TL04",
                    frame: 0
                },
                {
                    key: "TL05",
                    frame: 0
                }
            ],
            frameRate: 15,
            repeat: 3,
        },
        ["bottom_left_run"]: {
            key: "bottom_left_run",
            frames: [
                {
                    key: "BL02",
                    frame: 0
                },
                {
                    key: "BL03",
                    frame: 0
                },
                {
                    key: "BL04",
                    frame: 0
                },
                {
                    key: "BL05",
                    frame: 0
                }
            ],
            frameRate: 15,
            repeat: 3,
        },
    }

    /**获取休闲小猫纹理 */
    public static getIdleCatTexture(dir: CatDir, isStep: boolean): string {
        const animName: string = AnimMgr.getAnimKey(CatConfig.CAT_CONFIG[dir].animName, isStep);
        return (CatConfig.CAT_ANIM_CONFIG[animName].frames[0] as Phaser.Types.Animations.AnimationFrame).key;
    }
}